home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / gfx / misc / gnuplot-3.7src.lha / gnuplot-3.7src / gnuplot-3.7.lha / gnuplot-3.7 / corplot.c < prev    next >
C/C++ Source or Header  |  1998-10-29  |  3KB  |  82 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: corplot.c,v 1.8 1998/03/22 22:31:27 drd Exp $";
  3. #endif
  4.  
  5. /* GNUPLOT - corplot.c */
  6.  
  7. /*[
  8.  * Copyright 1986 - 1993, 1998   Thomas Williams, Colin Kelley
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted,
  12.  * provided that the above copyright notice appear in all copies and
  13.  * that both that copyright notice and this permission notice appear
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the complete modified source code.  Modifications are to
  18.  * be distributed as patches to the released version.  Permission to
  19.  * distribute binaries produced by compiling modified sources is granted,
  20.  * provided you
  21.  *   1. distribute the corresponding source modifications from the
  22.  *    released version in the form of a patch file along with the binaries,
  23.  *   2. add special version identification to distinguish your version
  24.  *    in addition to the base release version number,
  25.  *   3. provide your name and address as the primary contact for the
  26.  *    support of your modified version, and
  27.  *   4. retain our contact information in regard to use of the base
  28.  *    software.
  29.  * Permission to distribute the released version of the source code along
  30.  * with corresponding source modifications in the form of a patch file is
  31.  * granted with same provisions 2 through 4 for binary distributions.
  32.  *
  33.  * This software is provided "as is" without express or implied warranty
  34.  * to the extent permitted by applicable law.
  35. ]*/
  36.  
  37.  
  38. #include <stdio.h>
  39. #include <process.h>
  40. #include <dos.h>
  41. #if (defined(ATARI) || defined(MTOS)) && defined(__PUREC__)
  42. #include <plot.h>
  43. #endif
  44.  
  45. #define BOUNDARY 32768
  46. #define segment(addr) (FP_SEG(m) + ((FP_OFF(m)+15) >> 4));
  47. #define round(value,boundary) (((value) + (boundary) - 1) & ~((boundary) - 1))
  48.  
  49. char *malloc(),*realloc();
  50.  
  51. char prog[] = "gnuplot";
  52. char corscreen[] = "CORSCREEN=0";
  53.  
  54. main()
  55. {
  56. register unsigned int segm,start;
  57. char *m;
  58.     if (!(m = malloc(BOUNDARY))) {
  59.         printf("malloc() failed\n");
  60.         exit(1);
  61.     }
  62.     segm = segment(m);
  63.     start = round(segm,BOUNDARY/16);
  64.  
  65.     if (realloc(m,BOUNDARY+(start-segm)*16) != m) {
  66.         printf("can't realloc() memory\n");
  67.         exit(2);
  68.     }
  69.  
  70.     if ((segm = start >> 11) >= 8) {
  71.         printf("not enough room in first 256K\n");
  72.         exit(3);
  73.     }
  74.  
  75.     corscreen[sizeof(corscreen)-2] = '0' + segm;
  76.     if (putenv(corscreen))
  77.         perror("putenv");
  78.  
  79.     if (spawnlp(P_WAIT,prog,prog,NULL))
  80.         perror("spawnlp");
  81. }
  82.